import { BroadCastCall } from "../../broadCast/BroadCastCall";
import { MessageBlock } from "../../../../../Framework/MQ/MessageBlock";
import { SCopyPassInto } from "../../../../../Message/Public/SCopyPassInto";
import { CopyConfig } from "../../../resource/CopyConfig";
import { ECopyType } from "../../../../../Message/Public/ECopyType";
import { NetDispatcher } from "../../../../mvc/core/NetDispatcher";
import { ServerCommand } from "../../../mvc/ServerCommand";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
//class CopyEnterCopyCommand
    
    export  class CopyEnterCopyCommand extends BroadCastCall
    {
        constructor(arg1: Object)
        {
            super(arg1);
            return;
        }

        public /* override */ call(arg1: MessageBlock): void
        {
            var loc1=null;
            super.call(arg1);
            loc1 = arg1.messageBase as SCopyPassInto;
            var loc2=CopyConfig.instance.getInfoByCode(loc1.copyCode);
            if (loc2) 
            {
                _cache.copy.isInCopy = true;
                _cache.copy.isPractice = loc1.isPractice;
                _cache.copy.copyInfo = loc2;
                var loc3=loc2.copyType;
                switch (loc3) 
                {
                    case ECopyType._ECopySpa:
                    {
                        _cache.spa.isInSpa = true;
                        NetDispatcher.dispatchCmd(ServerCommand.SpaEnterSpaMap, loc1.copyCode);
                        break;
                    }
                    case ECopyType._ECopyCrossSpa:
                    {
                        _cache.spa.isInSpa = true;
                        NetDispatcher.dispatchCmd(ServerCommand.SpaEnterCrossSpaMap, loc1.copyCode);
                        break;
                    }
                    case ECopyType._ECopyArena:
                    {
                        if (!_cache.arena.isInArenaCopy) 
                        {
                            NetDispatcher.dispatchCmd(ServerCommand.ArenaCrossEnterCopy, null);
                        }
                        _cache.arena.isInArenaCopy = true;
                        break;
                    }
                    case ECopyType._ECopyArenaCross:
                    {
                        _cache.arenaCross.isInArenaCrossCopy = true;
                        break;
                    }
                    case ECopyType._ECopyGuild:
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.CopyRemoveLeaveButton));
                        break;
                    }
                    case ECopyType._ECopySixty:
                    {
                        _cache.copy.sixtyFirstFloorBossCleared = false;
                        break;
                    }
                }
                NetDispatcher.dispatchCmd(ServerCommand.Copy_EnterCopy, loc1.copyCode);
            }
            return;
        }
    }
